package day04;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Demo05 {
    public static void main(String[] args) {
        /*
         * 将中文转换为 ASCII
         */
        //将中文编码为 Base64
        String str = "今天您吃了么?";
        byte[] utf8 = str.getBytes(StandardCharsets.UTF_8);
        String base64 = Base64.getEncoder().encodeToString(utf8);
        System.out.println(base64);
        //Base64 解码为中文
        byte[] bytes = Base64.getDecoder().decode(base64);
        String s = new String(bytes, StandardCharsets.UTF_8);
        System.out.println(s);

    }
}
